<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class UserGroup extends Model
{
    
    protected $table = 'user_group';

    protected $primaryKey = 'usergroup_id';

    public $timestamps = false;

	protected $appends = ['usergroup_status_format', 'usergroup_operation', 'usergroup_checkbox'];
	
	public function getUsergroupStatusFormatAttribute()
    {
        $result = $this->usergroup_status ? '正常' : '禁用';
		return $result;
    }
	
	public function getUsergroupCheckboxAttribute()
    {
        $html = '<label><input type="checkbox" name="checkboxList" value="'.$this->usergroup_id.'" class="input-checkbox"><i>✓</i></label>';
		return $html;
    }
	
	public function getUsergroupOperationAttribute()
    {
        $html  = "<i class='fa fa-edit' onclick=layOpenView('/admin/usergroup/editview/{$this->usergroup_id}','90%','90%','管理员组信息编辑')></i>";
		if ($this->usergroup_status) {
			$html .= "<i class='fa fa-level-down ml-15' onclick=layChangeStatus('/admin/usergroup/status/{$this->usergroup_id}/0','禁用')></i>";
		} else {
			$html .= "<i class='fa fa-level-up ml-15' onclick=layChangeStatus('/admin/usergroup/status/{$this->usergroup_id}/1','启用')></i>";
		}
		$html .= "<i class='fa fa-trash-o ml-15' onclick=layListDel(this,'/admin/usergroup/destroy','{$this->usergroup_id}','tr')></i>";
		return $html;
    }


}
